﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Brain;
using Microsoft.Xna.Framework;
using Brain.Logic.AI;
using Brain.Logic3D.AI;
using Brain.Logic3D.PathFinding;
using Brain.Rendering;
using Microsoft.Xna.Framework.Graphics;
using DirectionalLight = SynapseGaming.LightingSystem.Lights.DirectionalLight;
using SynapseGaming.LightingSystem.Lights;

namespace Demos
{
    public class AIBattle : DemoScreen
    {
        public AIBattle()
        {
            InputFreeCamera3D Camera = new InputFreeCamera3D(this);
            Camera.AspectRatio = 1280 / 720f;
            Camera.FarPlane = 1000f;
            Engine.Instance.CameraManager.Camera3D = Camera;

            DirectionalLight dirLight = new DirectionalLight();
            dirLight.Direction = new Vector3(0.5f, -1, 0.5f);
            dirLight.ShadowType = SynapseGaming.LightingSystem.Shadows.ShadowType.AllObjects;
            dirLight.ShadowQuality = 2;
            Engine.Instance.RenderManager3D.SubmitLight(dirLight);

            AmbientLight light = new AmbientLight();
            light.Intensity = 0.4f;
            Engine.Instance.RenderManager3D.SubmitLight(light);

            Texture2D height = Engine.Instance.ContentManager.Load<Texture2D>("Textures\\terrain2");
            TerrainWorldObject terrain = new TerrainWorldObject(height, 0.1f);
            terrain.HeightMap.OffsetBetweenHeights = 10;
            Engine.Instance.RenderManager3D.InitializeTerrainDefaultRendering(terrain, true, true);
            terrain.Rendering = WorldObjectRendering.Rendered;

            Map3D map = new Map3D(1, terrain);

            // Make the City
            AIInfo blueTeam = new AIInfo();
            blueTeam.Info3D = new AIInfo3D();
            blueTeam.Info3D.FieldOfView = MathHelper.ToRadians(60);
            blueTeam.Info3D.Height = 10;
            blueTeam.Info3D.MaxDistance = 1000;
            blueTeam.Actions.Add(AIStatus.Idle, new IdleAction());
            blueTeam.Actions.Add(AIStatus.Fighting, new FightingAction());

            AIInfo redTeam = new AIInfo();
            redTeam.Info3D = new AIInfo3D();
            redTeam.Info3D.FieldOfView = MathHelper.ToRadians(60);
            redTeam.Info3D.Height = 10;
            redTeam.Info3D.MaxDistance = 1000;
            redTeam.Actions.Add(AIStatus.Idle, new IdleAction());
            redTeam.Actions.Add(AIStatus.Fighting, new FightingAction());

            WorldObject box = new WorldObject("Models\\model_box");
            box.Rendering = WorldObjectRendering.Rendered;
            ArtificialIntelligence3D AIblue = new ArtificialIntelligence3D(blueTeam, map.Nodes[500], map, box);
            AIblue.SwitchStatus(AIStatus.Fighting);
            
            WorldObject box2 = new WorldObject("Models\\model_box");
            box2.Rendering = WorldObjectRendering.Rendered;
            ArtificialIntelligence3D AIred = new ArtificialIntelligence3D(redTeam, map.Nodes[1000], map, box2);
            AIred.SwitchStatus(AIStatus.Fighting);
        }
    }
}
